#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
//int main()
//{
//	char ch;
//	while ((ch = getchar()) != '\n')
//	{
//		if (ch % 2 != 0 && (ch >= 'a' && ch <= 'z'))
//			ch = ch - 'a' + 'A';
//		putchar(ch);
//	}
//	printf("\n");
//	return 0;
//}
//
//void Find(int* nums, int k, int* count, int left, int right)
//{
//    while (left <= right)
//    {
//        int mid = (right - left) / 2 + left;
//        if (nums[mid] > k)
//            right = mid - 1;
//        else if (nums[mid] < k)
//            left = mid + 1;
//        else
//        {
//            (*count)++;
//            Find(nums, k, count, left, mid - 1);
//            Find(nums, k, count, mid + 1, right);
//            return;
//        }
//    }
//
//}
//
//int GetNumberOfK(int* nums, int numsLen, int k) {
//    int count = 0;
//    if (nums[0] > k)
//        return 0;
//
//    Find(nums, k, &count, 0, numsLen - 1);
//
//    return count;
//}
//int convertInteger(int A, int B) {
//    int c = A ^ B;
//    int d = 0x8000000;
//    int count = 0;
//    printf("%d\n", c);
//    while (d)
//    {
//        if ((c & d) > 0)
//            count++;
//        d >>= 1;
//    }
//    return count;
//}
//int convertInteger(int A, int B) {
//    unsigned int c = A ^ B;
//    int count = 0;
//    while (c)
//    {
//        c = (c & (c - 1));
//        count++;
//    }
//    return count;
//}
//int main()
//{
//    int count = convertInteger(29, 15);
//    printf("%d\n", count);
//
//    return 0;
//}
#define OFFSETOF(type,member) (size_t)&(((type *)0)->member)
#define EXCHANGE(num) ((num & 0xAAAAAAAA) >> 1) | ((num & 0x55555555) << 1)

struct foo {
	char a;
	char b[10];
	char c;
};

int main()
{
	printf("offsetof(struct foo,a) is %d\n", (int)OFFSETOF(struct foo, a));
	printf("offsetof(struct foo,b) is %d\n", (int)OFFSETOF(struct foo, b));
	printf("offsetof(struct foo,c) is %d\n", (int)OFFSETOF(struct foo, c));

	int a = 1;
	int b = EXCHANGE(a);
	printf("b = %d", b);

	return 0;
}

int missingNumber(int* nums, int numsSize) {

    int ret = 0;

    int min = 0;

    int range = numsSize + 1;
    int* num = (int*)malloc(sizeof(int) * range);
    memset(num, 0, sizeof(int) * range);

    for (int i = 0; i < numsSize; i++)
        num[nums[i] - min]++;

    for (int i = 0; i < range; i++)
        if (num[i] == 0)
        {
            ret = i + min;
        }

    free(num);
    return ret;
}
void _rotate(int* nums, int numsSize, int left, int right)
{
    while (left < right)
    {
        int temp = nums[left];
        nums[left] = nums[right];
        nums[right] = temp;


        left++;
        right--;
    }
}


void rotate(int* nums, int numsSize, int k) {
    if (numsSize == 1)
        return;


    k = k % numsSize;


    int _k;
    _k = numsSize - k;
    _rotate(nums, numsSize, 0, _k - 1);
    _rotate(nums, numsSize, _k, numsSize - 1);
    _rotate(nums, numsSize, 0, numsSize - 1);



}